# Contributor: Galen Abell <galen@galenabell.com>
# Maintainer: Galen Abell <galen@galenabell.com>
pkgname=khal
pkgver=0.11.2
pkgrel=1
pkgdesc="CLI calendar application build around CalDAV"
url="https://lostpackets.de/khal"
arch="noarch"
license="MIT"
options="net"
depends="
	python3
	py3-atomicwrites
	py3-click
	py3-click-log
	py3-configobj
	py3-dateutil
	py3-icalendar
	py3-tz
	py3-tzlocal
	py3-urwid
	py3-xdg
	"
makedepends="py3-setuptools py3-setuptools_scm py3-sphinx py3-sphinxcontrib-newsfeed bash"
checkdepends="py3-packaging py3-pytest py3-freezegun py3-hypothesis vdirsyncer"
subpackages="
	$pkgname-doc
	$pkgname-pyc
	$pkgname-bash-completion
	$pkgname-zsh-completion
	$pkgname-fish-completion
	"
source="https://files.pythonhosted.org/packages/source/k/khal/khal-$pkgver.tar.gz"
case "$CARCH" in
s390x)
	# E AssertionError: assert '09:30-10:30: Great Event' in ''
	# E  +  where '' = <Result okay>.output
	options="!check"
	;;
esac

build() {
	python3 setup.py build
	make -C doc man PYTHONPATH="$PWD"
	for shell in bash zsh fish; do
		PYTHONPATH="$PWD" _KHAL_COMPLETE=${shell}_source python3 ./bin/khal >khal.$shell
	done
}

check() {
	# some locale tests fail
	pytest -v \
		--deselect tests/cal_display_test.py::test_vertical_month_unicode \
		--deselect tests/cal_display_test.py::test_vertical_month_unicode_weekdeays \
		--deselect tests/cal_display_test.py::test_vertical_month_unicode_weekdeays_gr \
		--deselect tests/cal_display_test.py::test_vertical_month_abbr_fr
}

package() {
	python3 setup.py install --skip-build --root="$pkgdir"
	install -Dm644 doc/build/man/$pkgname.1 "$pkgdir"/usr/share/man/man1/$pkgname.1

	install -Dm644 khal.bash \
		"$pkgdir"/usr/share/bash-completion/completions/khal
	install -Dm644 khal.zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_khal
	install -Dm644 khal.fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/khal.fish
}

sha512sums="
378a81c9f9a21a4af77ccdc5eabbcb62d109bcf5f2e2d3407c6fb504e15efd7dde545428153673cfeb46f60d9e9921efcad6805db2944884f124053e7922ab45  khal-0.11.2.tar.gz
"
